package com.google.code.sysarch.v3.pre;

/**
 * @author Alexander Wirth
 */

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;

public class Game {
	
	/** GameWindow used to run the game */
	private GameWindow window;
	/** InputManager used to react to input events */
	private InputManager input;

	public static void main(String[] args) throws InterruptedException {
		
		Game game = new Game();
		game.input = InputManager.get();		
		game.window = new GameWindow(1024, 768, 60);
		game.window.setWindowTitle("Distributed Battleships");
		game.window.setCallback(game);
		game.window.antialias(false);
		game.window.setBackground(Color.BLACK);
		game.window.startGame();
		
	}
	
	Game() {
		
	}
	
	public Game get() {
		return this;
	}
	
	/**
	 * Render the scene
	 * @param g Graphics object to draw on
	 */
	public void render(Graphics2D g) {
		// TODO implement rendering
		g.setColor(Color.WHITE);
		g.drawString("This String is drawn by the render() method in Game.java that should be used for all rendering.", 100, 300);
		g.drawString("This application may be closed via the escape key.", 100, 350);
		g.drawString("Whether the escape key has been pressed is checked in the update(long delta) method in Game.java,", 100, 400);
		g.drawString("which should be used to update everything that is currently happening in the game.", 100, 420);
		g.drawString("Do not hesitate to contact alexwirth.mail@gmail.com for any information you need.", 100, 500);
	}
	
	/**
	 * Update the scene
	 * @param delta Time in seconds that passed since the last call of this method
	 */
	public void update(double delta) {
		// TODO implement updating
		if (input.isKeyPressed(KeyEvent.VK_ESCAPE)) {
			window.quitGame();
		}
	}

}
